package de.itagile.hypersphere

class EntityTemplateGeneratesFieldTest extends GroovyTestCase {
	
	def cmpfield = [name:"id", type:"java.lang.Integer", column:"ID_COLUMN"]
	def entityFieldTemplate = new EntityFieldTemplate()
	
	void testGeneratesField() {
		def result = entityFieldTemplate.getField()(cmpfield)
		assertEquals("private java.lang.Integer id;", result)
	}
	
	void testGeneratesGetter() {
		def result = entityFieldTemplate.getGetter()(cmpfield)
		assertEquals('@Column(name = "ID_COLUMN")', result[0])
		assertEquals("public java.lang.Integer getId() {", result[1])
		assertEquals("return id;", result[2])
		assertEquals("}", result[3])
	}
	
	void testGeneratesSetter() {
		def result = entityFieldTemplate.getSetter()(cmpfield)
		assertEquals("public void setId(java.lang.Integer id) {", result[0])
		assertEquals("this.id = id;", result[1])
		assertEquals("}", result[2])
	}
}